<template>
  <div class="login">
    <h4>学籍管理系统</h4>
    <el-form label-width="80px" :model="loginDate">
      <el-form-item label="账号">
        <el-input placeholder="请输入账号" v-model="loginDate.name"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input
          placeholder="请输入密码"
          v-model="loginDate.password"
          show-password
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button class="sub-button" @click="toHome" type="primary">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// @ is an alias to /src
import { useRouter } from "vue-router";
import { reactive } from "vue";
import { ElMessage } from "element-plus";

export default {

  name: "Login",
  setup() {
    let loginDate = reactive({
      name: "",
      password: "",
    });

    const router = useRouter();
    const toHome = () => {
      if (!loginDate.name || !loginDate.password) {
        ElMessage.warning({
          message: "警告,请先填写账号和密码",
          type: "warning",
        });
        return;
      }else if(loginDate.name!="lyx" || loginDate.password!="21233825"){
         ElMessage.warning({
          message: "账号或密码错误！",
          type: "warning",
        });
        return;
      }
      router.push({
        name: "Home",
      });
    }
    return {
      toHome,
      loginDate,
    };
  },
};
</script>

<style scoped>
.login {
  width: 500px;
  margin: 150px auto;
  border: 1px solid #2c0ddb38;
  border-radius: 10px;
  padding: 20px;
}
h4 {
  text-align: center;
}
.sub-button {
  width: 100%;
}
</style>
